<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

    <head>
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link th:href="@{/assets/expand/images/favicon.ico}" rel="icon">
        <title th:text="${webconfig.get('TITLE')}">首页</title>
        <link rel="stylesheet" th:href="@{/assets/common/libs/layui/css/layui.css}"/>
        <link rel="stylesheet" th:href="@{/assets/common/module/admin.css}"/>
    </head>

    <body class="layui-layout-body">

        <div class="layui-layout layui-layout-admin">

            <!-- 头部 -->
            <th:block th:insert="pages/common/_header :: header"/>

            <!-- 侧边栏 -->
            <th:block th:insert="pages/common/_sidebar :: sidebar"/>

            <!-- 主体部分 -->
            <th:block th:insert="pages/common/_body :: body"/>

            <!-- 底部 -->
            <th:block th:insert="pages/common/_footer :: footer"/>

        </div>

        <!-- 加载动画，移除位置在common.js中 -->
        <th:block th:insert="pages/common/loading :: loading"/>

        <!--@/* 加入contextPath属性和session超时的配置 */-->
        <script type="text/javascript">
            var Kong = {
                ctxPath: "[(${ctxPath})]",
                version: "[(${version})]"
            };
        </script>
        <script type="text/javascript" th:src="@{/assets/common/libs/layui/layui.js}"></script>
        <script type="text/javascript" th:src="@{/assets/common/js/common.js}"></script>

        <script>
            layui.use(['layer', 'element', 'admin', 'index', 'ax'], function () {
                var $ = layui.jquery,
                    layer = layui.layer,
                    admin = layui.admin,
                    index = layui.index,
                    $ax = layui.ax;

                // 默认加载主页
                index.loadHome({
                    menuPath: Kong.ctxPath + "/index",
                    menuName: '<i class="layui-icon layui-icon-home"></i>'
                });

                //获取支持的语言列表
                /*var ajax = new $ax(Feng.ctxPath + "/translation/languages", function (data) {
                    for (var i = 0; i < data.data.length; i++) {
                        var code = data.data[i].code;
                        var description = data.data[i].description;
                        $("#languageDiv").append('<dd lay-unselect><a id="tran-' + code + '" href="javascript:;">' + description + '</a></dd>');

                        //设置监听事件，设置点击按钮切换当前系统语言
                        (function (code) {
                            $('#tran-' + code).click(function () {
                                var ajax = new $ax(Feng.ctxPath + "/translation/changeUserTranslation", function (data) {
                                    window.location.href = Feng.ctxPath + "/";
                                }, function (data) {
                                    layer.msg("切换多语言失败！" + data.responseJSON.message, {icon: 5, anim: 6});
                                });
                                ajax.set("code", code);
                                ajax.start();
                            });
                        })(code);
                    }
                }, function (data) {
                    layer.msg("获取语言列表失败！" + data.responseJSON.message, {icon: 5, anim: 6});
                });
                ajax.start();*/

                // 加载当前语言字典并缓存
                /*var getUserTranslationAjax = new $ax(Feng.ctxPath + "/translation/getUserTranslation", function (data) {
                    layui.data('system', {
                        key: "lang",
                        value: data.data
                    });
                }, function (data) {
                    layer.msg("加载语言字典失败！" + data.responseJSON.message, {icon: 5, anim: 6});
                });
                getUserTranslationAjax.start();*/


                // 修改密码点击事件
                $('#setPsw').click(function () {
                    admin.open({
                        id: 'pswForm',
                        type: 2,
                        title: "修改密码",
                        shade: 0,
                        content: '[[${ctxPath}]]/sys/user-chpwd'
                    });
                });

                // 退出登录点击事件
                $('#btnLogout').click(function () {
                    admin.confirm('确定退出系统？', {icon: 3, title: '提示'}, function (index) {
                        //do something
                        window.location.href = Kong.ctxPath + "/logout"
                        layer.close(index);
                    });
                });
            });
        </script>
    </body>

</html>